﻿namespace NumericalSolution {
  class Diffsuion1DExplicit : Diffusion1D {
    public override double[] Next() {
      base.Age();

      double s = (p_alpha * p_deltaTime) / (p_deltaX * p_deltaX);
      p_current_u[0] = 0.0;
      for (int i = 1; i < p_numberOfNodes - 1; i++) {
        p_current_u[i] = s * p_previous_u[i - 1]
                       + (1 - 2 * s) * p_previous_u[i]
                       + s * p_previous_u[i + 1];
      }
      p_current_u[p_numberOfNodes - 1] = 0.0;

      return p_current_u;
    }

  }
}
